package com.yakumosakura.yakumoblade.specialattacks.v1;


import com.yakumosakura.yakumoblade.entity.hexgram.a.EntitySpiralSwordsSon;
import mods.flammpfeil.slashblade.SlashBlade;
import mods.flammpfeil.slashblade.entity.EntitySpiralSwords;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;


public class SpiralSwordEx {








    public static void doslash(LivingEntity sender) {


        sender.getMainHandItem().getCapability(ItemSlashBlade.BLADESTATE).ifPresent((state) -> {

            Level worldIn = sender.level();


            int count = 12+(state.getProudSoulCount()/1000);



            for (int i = 0; i < count; i++) {
                EntitySpiralSwords ss = new EntitySpiralSwords(
                        SlashBlade.RegistryEvents.SpiralSwords, worldIn);

                worldIn.addFreshEntity(ss);

                ss.setOwner(sender);
                ss.setColor(state.getColorCode());
                ss.setRoll(0);
                ss.setDamage(5);
                // force riding
                ss.startRiding(sender, true);

                ss.setDelay(360 / count * i);


            }
            for (int i = 0; i < count; i++) {
                EntitySpiralSwordsSon ss = new EntitySpiralSwordsSon(
                        SlashBlade.RegistryEvents.SpiralSwords, worldIn);

                worldIn.addFreshEntity(ss);

                ss.setOwner(sender);
                ss.setColor(state.getColorCode());
                ss.setRoll(0);
                ss.setDamage(5);
                // force riding
                ss.startRiding(sender, true);

                ss.setDelay(360 / count * i);


            }
        });


    }
}
